package com.zzyl.controller.manager;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingLevelPageQueryDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
@Slf4j
public class NursingLevelController {
    @Autowired
    NursingLevelService nursingLevelService;
    @GetMapping("listByPage")
    @ApiOperation("分页查询护理等级信息")
    public ResponseResult<PageBean<NursingLevelVo>> pageQuery(NursingLevelPageQueryDto nursingLevelPageQueryDto){
        log.info("分页查询护理等级信息:{}",nursingLevelPageQueryDto);
        PageBean<NursingLevelVo> nursingLevelVoPageBean = nursingLevelService.pageQuery(nursingLevelPageQueryDto);
        return ResponseResult.success(nursingLevelVoPageBean);
    }
    @PostMapping("insert")
    @ApiOperation("插入护理等级信息")
    public ResponseResult<Void> insertNursingLevel(@RequestBody NursingLevelVo nursingLevelVo){
        log.info("插入护理等级信息:{}",nursingLevelVo);
        nursingLevelService.insertNursingLevel(nursingLevelVo);
        return ResponseResult.success();
    }
    @GetMapping("{id}")
    @ApiOperation("根据ID查询护理等级信息")
    public ResponseResult<NursingLevelVo> selectById(@PathVariable Long id){
        log.info("根据id查询护理等级信息:{}",id);
        NursingLevelVo nursingLevelVo = nursingLevelService.selectById(id);
        return ResponseResult.success(nursingLevelVo);

    }
    @PutMapping("update")
    @ApiOperation("更新护理等级信息")
    public ResponseResult<Void> updeteNursingLevel(@RequestBody NursingLevelDto dto){
        log.info("更新护理等级信息:{}",dto);
        nursingLevelService.updateNursingLevel(dto);
        return ResponseResult.success();
    }
    @DeleteMapping("delete/{id}")
    @ApiOperation("删除护理等级信息")
    public ResponseResult<Void> deleteNursingLevel(@PathVariable Long id){
        log.info("删除护理等级信息,{}",id);
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }
    @PutMapping("{id}/status/{status}")
    @ApiOperation("启用、禁用护理等级")
    public ResponseResult<Void> enableOrDisable(@PathVariable Long id ,@PathVariable Integer status){
        log.info("启用，禁用护理等级:{},{}",id,status);
        nursingLevelService.enableOrDisable(id,status);
        return ResponseResult.success();

    }
    @GetMapping("listAll")
    @ApiOperation("查询所有护理等级信息")
    public ResponseResult<List<NursingLevelVo>> getAllList(){
        List<NursingLevelVo> nursingLevelVoList = nursingLevelService.getAllList();
        return ResponseResult.success(nursingLevelVoList);
    }
}